<template>
  <div class='sign_code'>
    <c-title :text="text"></c-title>
    <div class="bg"></div>
    <canvas id="qrccode-canvas"></canvas>
  </div>
</template>

<script>
import QRCode from "qrcode";
var canvas = "";
export default {
  data() {
    return {
      text: "转证码"
    };
  },
  mounted() {
    // this.init()
    this.$nextTick(function() {
      // DOM操作
      canvas = document.getElementById("qrccode-canvas");
      //   this.createQrc();
      this.createQrc();
    });
  },
  methods: {
    createQrc() {
      let _url = document.location.href;
      _url =  _url.replace(/sign_in_subscribe_code/,'sign_in_subscribe_shift_card');
      console.log(_url)
      QRCode.toCanvas(canvas, _url, error => {
        if (error) {
          console.log(error);
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
.sign_code {
  padding: 0.625rem;

  #qrccode-canvas {
    width: 9.875rem !important;
    height: 9.875rem !important;
  }

  .bg {
    position: fixed;
    z-index: -1;
    width: 100%;
    height: 12rem;
    background: #fff;
  }
}

</style>
